#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File    :   smooth_data.py
@Time    :   2021/12/03 11:52:31
@Author  :   glx 
@Version :   1.0
@Contact :   18095542g@connect.polyu.hk
@Desc    :   None
"""

# here put the import lib

import numpy as np
from scipy.ndimage import gaussian_filter
import matplotlib.pyplot as plt
import pandas as pd

import os


def do_smooth(data, sigma=1):
    """do data smooth and save figure in folder "smooth" """
    data_smoothed = gaussian_filter(data, sigma)
    data_smoothed = pd.DataFrame(
        {"Freq": data_smoothed, "Ts": data.index},
        columns=["Freq", "Ts"],
    )
    # print(data_smoothed.head())
    print("smooth freq done".center(100, "="))
    return data_smoothed


if __name__ == "__main__":
    import get_matlab_data as gmd

    # 读数据
    data = gmd.get_data()
    # 做平滑
    do_smooth(data, sigma=1)
